package com.nut.lmsc.event;

import com.nut.lmsc.enums.MessageTagsEnum;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import org.springframework.transaction.event.TransactionPhase;
import org.springframework.transaction.event.TransactionalEventListener;

/**
 * 事务提交监听器
 **/
@Component
@Slf4j
public class TransactionCommitListener {

    @TransactionalEventListener(phase = TransactionPhase.AFTER_COMMIT)
    public void get(TransactionCommitEvent event) {
        log.info("event_listener={}", event);
        String destination = event.getTopic() + ":" + event.getTag();
        System.out.println(event.getMessage());
        System.out.println(destination);


        MessageTagsEnum messageTagsEnum = MessageTagsEnum.valueOf(event.getTag());

        switch (messageTagsEnum) {
            case ORDER_CREATE:




                break;
            case STATUS_CHANGE:
                break;
            default:
                break;
        }


    }

    public static void main(String[] args) {

        MessageTagsEnum messageTagsEnum2 = MessageTagsEnum.valueOf("ORDER_CREATE");
        System.out.println(messageTagsEnum2);
    }

}
